package com.atguigu.gmall.common.retryer;

import feign.RetryableException;
import feign.Retryer;
import lombok.extern.slf4j.Slf4j;

/**
 * @Description
 * @Return
 * @Author https://weiranyi.github.io
 * @Date Created in 2022-12-10 16:18
 **/
@Slf4j
public class Retryer3 implements Retryer {
    int count = 3;
    int current = 0;

    @Override
    public void continueOrPropagate(RetryableException e) {
        log.info("正在重试第{}次...", current + 1);
        if (current++ >= count) {
            throw e;
        }
    }

    @Override
    public Retryer clone() {
        return new Retryer3();
    }
}
